/*
 * @Description: 数组基础知识
 * @Version: 1.0
 * @Author: marshal
 * @Date: 2022-06-20 09:14:00
 * @LastEditors: marshal
 * @LastEditTime: 2023-09-10 15:37:08
 */
#include <stdio.h>

int main()
{
    // 1. 数组的声明与赋值
    // 1.1 先声明后赋值
    int a[2];
    a[0] = 10;
    a[1] = 25;
    // 1.2 声明并赋值
    int b[3] = {10, 20, 30};
    // 1.3 声明并赋值
    int c[] = {1, 2, 4};

    // 2. 数组的访问
    // 2.1 通过下标访问
    printf("=============get value by index==============\n");
    printf("a[0] = %d\n", a[0]);
    printf("a[1] = %d\n", a[1]); 
    // 2.2 通过指针来访问
    printf("=============get value by pointer==============\n");
    int *pa;
    pa = a;
    printf("a[0] = %d\n", *pa);
    printf("a[0] = %d\n", *(pa + 1));
}